/**
 * Created by Yamazhiki on 14/01/2017.
 */
/**
 * 平台类型
 */
import {SocketHelper} from "./SocketHelper";
export enum PlatfromType {
    PlatfromType_None = 0,
    PlatfromType_Live = 1,		// Live平台
}

/**
 * 获取网关命令
 */
export enum GatewayType {
    Gateway_None        = 0,
    Gateway_GetFrontend = 1,				// 获取前端ip及端口
    Gateway_Count,
}

class IFrontendVo {
    ip?: string         //17
    port?: number        //4
    dbId?: number       //4
    srvId?: number      //4
    lineId?: number     //4
    status?: number     //4
    userCount?: number  //4
}

export interface ITcm_Gateway_GetFrontend {
    uid: number //u 8
}

export class Tcm_Gateway_GetFrontend implements ITcm_Gateway_GetFrontend, IBufferable {
    uid: number

    constructor(obj: ITcm_Gateway_GetFrontend) {
        this.uid = obj.uid
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafeSlow(8)
        let helper = new SocketHelper()
        helper.putUInt64(buffer, this.uid)
        return buffer
    }

}

export interface ITsm_Gateway_GetFrontend {
    fVo: IFrontendVo
}

export class Tsm_Gateway_GetFrontend implements ITsm_Gateway_GetFrontend {
    fVo: IFrontendVo;

    constructor(buffer) {
        let vo: IFrontendVo = {};
        let parse = new SocketHelper();
        vo.ip = parse.getString(buffer, 17);
        vo.port = parse.getUInt(buffer);
        vo.dbId = parse.getInt(buffer);
        vo.srvId = parse.getInt(buffer);
        vo.lineId = parse.getInt(buffer);
        vo.status = parse.getInt(buffer);
        vo.userCount = parse.getInt(buffer);
        this.fVo = vo;
    }
}
